<?php


namespace App\Validators;


class AuthValidator extends BaseValidator
{
    protected $rules = [
        'id' => ['required', 'numeric'],
        'name' => ['required'],
        'nums' => ['required', 'numeric'],
        'page' => ['required', 'numeric'],
        'group_id' => ['required', 'numeric'],
        'sort' => ['required', 'numeric'],
        'parent_id' => ['required', 'numeric'],
        'auth_code' => ['required'],
        'nickname' => ['required'],
        'phone' => ['required', 'regex: /^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/'],
        'sex' => ['required', 'numeric'],
        'password' => ['required', 'min:6', 'max:16'],
        'confirm_password' => ['required', 'min:6', 'max:16'],
        'edit_password' => ['min:6', 'max:16'],
        'user_type' => ['required', 'numeric'],
        'role_id' => ['required', 'numeric'],
        'auth_id' => ['required', 'numeric'],
        'type' => ['required', 'numeric'],
        'user_id' => ['required', 'numeric'],
        'money' => ['required', 'numeric'],
        'status' => ['required', 'numeric'],
        'username' => ['required'],
    ];

    protected $msgs = [
        'id.required' => 'ID必填',
        'id.numeric' => 'ID错误',
        'user_id.required' => '用户ID必填',
        'user_id.numeric' => '用户ID错误',
        'name.required' => '名称不能为空',
        'page.required' => '请上传分页',
        'page.numeric' => '页数格式错误',
        'group_id.required' => '请选择分组',
        'group_id.numeric' => '分组参数格式有误',
        'sort.required' => '请填写序号',
        'sort.numeric' => '序号格式有误',
        'parent_id.required' => '上级标识必填',
        'parent_id.numeric' => '关联字段有误',
        'auth_code.required' => '权限标识不能为空',
        'phone.required' => '手机号不能为空',
        'phone.regex' => '手机号格式错误',
        'sex.required' => '请选择性别',
        'sex.numeric' => '性别格式错误',
        'password.required' => '密码不能为空',
        'password.min' => '密码长度必须在6位以上',
        'password.max' => '密码长度必须在16位以下',
        'confirm_password.required' => '确认密码不能为空',
        'confirm_password.min' => '确认密码长度必须在6位以上',
        'confirm_password.max' => '确认密码长度必须在16位以下',
        'edit_password.min' => '密码长度必须在6位以上',
        'edit_password.max' => '密码长度必须在16位以下',
        'user_type.required' => '请选择用户类型',
        'user_type.numeric' => '用户类型有误',
        'nickname.required' => '请填写昵称',
        'role_id.required' => '角色ID必填',
        'role_id.numeric' => '角色ID类型有误',
        'auth_id.required' => '权限ID必填',
        'auth_id.numeric' => '权限ID类型有误',
        'type.required' => '类型有误',
        'type.numeric' => '类型有误',
        'nums.required' => '数量必填',
        'nums.numeric' => '数量类型有误',
        'money.required' => '金额必填',
        'money.numeric' => '金额类型有误',
        'status.required' => '状态必填',
        'status.numeric' => '状态类型有误',
        'username.required' => '请填写用户名'
    ];

    protected $scenes = [
        'groupAdd' => ['name'],
        'groupEdit' => ['id', 'name'],
        'groupDel' => ['id'],
        'roleAdd' => ['name', 'group_id'],
        'roleList' => ['group_id'],
        'roleEdit' => ['id', 'name'],
        'roleDel' => ['id'],
        'menuAdd' => ['name', 'sort', 'parent_id', 'auth_code', 'status'],
        'menuEdit' => ['id', 'name', 'sort', 'parent_id', 'auth_code', 'status'],
        'accountAdd' => ['username', 'phone', 'sex', 'password', 'role_id'],
        'adminAdd' => ['username', 'phone', 'sex', 'password'],
        'accountEdit' => ['id', 'username', 'phone', 'sex', 'role_id', 'edit_password'],
        'setRoleAuth' => ['type', 'auth_id'],
        'login' => ['username', 'password'],
        'setOpAuth' => ['parent_id', 'auth_code', 'name'],
        'resetPassword' => ['id', 'password', 'confirm_password'],
        'userAdd' => ['nickname', 'phone', 'password', 'sex', 'user_type'],
        'robotAdd' => ['nums'],
        'recharge' => ['user_id', 'money'],
        'setBalanceStatus' => ['user_id', 'status'],
        'checkPhone' => ['phone'],
    ];
}
